package common;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/2/17.
 */

public class BaseFragmentAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragmentList;
    private String[] tabs;


    public BaseFragmentAdapter(FragmentManager fm, ArrayList<Fragment> fragmentList) {
        super(fm);
        this.fragmentList = fragmentList;
    }
    public BaseFragmentAdapter(FragmentManager fm, ArrayList<Fragment> fragmentList,String[] tabs) {
        super(fm);
        this.fragmentList = fragmentList;
        this.tabs = tabs;
    }


    @Override
    public android.support.v4.app.Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabs[position];
    }
}
